#!/usr/bin/python3
"""
扑克游戏
"""
import random
from enum import Enum, unique


@unique
class Suite(Enum):
    """花色"""
    SPADE, HEART, GLUB, DIAMOND = range(4)


class APoker:
    """一张纸牌的类"""

    def __init__(self, poker_suit, poker_num):
        self.poker_suit = poker_suit
        self.poker_num = poker_num

    def __str__(self):
        suite = ["黑桃", "红桃", "梅花", "方块"]
        value = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']
        return f'{suite[self.poker_suit.value]}{value[self.poker_num]}' 
        

    def __repr__(self):
        return self.__str__()


class Poker:
    """一副扑克牌"""

    def __init__(self):
        self.poker = []
        for val in range(13):
            for suite in Suite:
                a_poker = APoker(suite, val)
                self.poker.append(a_poker)

    def shuffle(self):
        """洗牌"""
        random.shuffle(self.poker)

    def deal(self, deal_num):
        """发牌"""
        i = 0
        list_poker = []
        if deal_num > len(self.poker):
            print('牌不够了,请换一副新扑克:')
        else:
            while i < deal_num:
                list_poker.append(self.poker[i])
                del self.poker[i]
                i += 1
        return list_poker


class Player:
    """玩家类"""

    def __init__(self, name):
        self.name = name
        self.take_cards = []

    def draw_poker(self, deal_num, method):
        """摸牌"""
        self.take_cards += method(deal_num)
        self.take_cards.sort(key=lambda x: x.poker_num)
    def paly_cards(self, index=0):
        """出牌"""
        if index > len(self.take_cards) - 1:
            print('请重新出牌')
        else:
            paly_card = self.take_cards.pop(index)
            print(paly_card)

    def redraw(self):
        """重新抽牌"""
        self.take_cards[self.name] = []


def main():
    """主函数"""
    poker = Poker()
    poker.shuffle()
    game = Player('小明')
    game.draw_poker(3, poker.deal)
    game.draw_poker(4, poker.deal)
    print(game.take_cards)

if __name__ == '__main__':
    main()
